import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";

// MARK: - local
// const API = {
//   main: 'http://localhost:8034',
//   rds: 'http://localhost:8034',
//   bcm: 'http://enjoyit-wh.tpddns.cn:4780'
// }

// MARK: - 济南110 RDSCS
const API = {
  main: "https://enjoymain.quanqiuwa.com",
  rds: 'http://60.208.83.246:8050',
  bcm: 'http://enjoyit-wh.tpddns.cn:4780',
  crm: 'http://127.0.0.1:9006',
  rmis: "https://enjoyapi.quanqiuwa.com",
}

// MARK: - RDSYLBCS 昂捷信息
// const API = {
//   main: 'http://60.208.83.246:8010',
//   rds: 'http://60.208.83.246:8010',
//   bcm: 'http://enjoyit-wh.tpddns.cn:4780'
// }

// MARK: - 广东万民商业集团 GDWM08
// const API = {
//   main: 'http://119.45.221.89:9006',
//   rds: 'http://119.45.221.89:9006',
//   bcm: 'http://enjoyit-wh.tpddns.cn:4780'
// }

// MARK: - 沂南县君悦商贸有限公司 YNJY56
// const API = {
//     main: 'http://222.174.173.244:19008',
//     rds: 'http://222.174.173.244:19008',
//     bcm: 'http://222.174.173.244:19008'
// }

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [uni()],
  server: {
    proxy: {
      // Using the proxy instance
      '/api/': {
        target: API.main,
        changeOrigin: true,
        configure: (proxy, options) => {
          // proxy will be an instance of 'http-proxy'
        },
      },
      '/mbmv5/Enjoy/Service': {
        target: API.main,
        changeOrigin: true,
        configure: (proxy, options) => {
          // proxy will be an instance of 'http-proxy'
        },
      },
      '/main/api/Enjoy/Service': {
        target: API.rds,
        changeOrigin: true,
        configure: (proxy, options) => {
          // proxy will be an instance of 'http-proxy'
        },
      },
      '/report/api/Enjoy/Service': {
        target: API.rds,
        changeOrigin: true,
        configure: (proxy, options) => {
          // proxy will be an instance of 'http-proxy'
        },
      },
      '/rds-bc/api/Enjoy/Service': {
        target: `${API.rds}`,
        changeOrigin: true,
        configure: (proxy, options) => {
          // proxy will be an instance of 'http-proxy'
        },
      },
      '/rds-sc/api/Enjoy/Service': {
        target: `${API.rds}`,
        changeOrigin: true,
        configure: (proxy, options) => {
          // proxy will be an instance of 'http-proxy'
        },
      },
      '/rds-fc/api/Enjoy/Service': {
        target: `${API.rds}`,
        changeOrigin: true,
        configure: (proxy, options) => {
          // proxy will be an instance of 'http-proxy'
        },
      },
      '/rds-api/api/Enjoy/Service': {
        target: `${API.rds}`,
        changeOrigin: true,
        configure: (proxy, options) => {
          // proxy will be an instance of 'http-proxy'
        },
      },
	  '/enjoycrm/api/Enjoy/Service': {
	    target: `${API.crm}`,
	    changeOrigin: true,
	    configure: (proxy, options) => {
	      // proxy will be an instance of 'http-proxy'
	    },
	  },
      '/bcm': {
        target: API.bcm,
        changeOrigin: true,
        configure: (proxy, options) => {
          // proxy will be an instance of 'http-proxy'
        },
      },
      '/enjoy/service': {
        target: API.rmis,
        changeOrigin: true,
        configure: (proxy, options) => {
          // proxy will be an instance of 'http-proxy'
        },
      }
    },
    cors: { origin: true },
  }
});
